package priv.zgh.forum.game.controller;


import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import priv.zgh.forum.game.entity.Type;
import priv.zgh.forum.game.service.TypeService;
import priv.zgh.forum.game.vo.OneGameType;
import priv.zgh.forum.utils.R;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZGH
 * @since 2022-04-19
 */
@CrossOrigin
@RestController
@RequestMapping("/game/type")
public class TypeController {
    TypeService typeService;
    @Autowired
    public void setTypeService(TypeService typeService) {
        this.typeService = typeService;
    }

    @ApiOperation("获取所有类型，以child的形式表示子级")
    @GetMapping("/getAllType")
    public R getAllSubject(){
        List<OneGameType> list = typeService.getAllGameType();
        return R.ok().data("list",list);
    }

    @ApiOperation("获取所有类型，以child的形式表示子级")
    @GetMapping("/getInfoById/{id}")
    public R getInfoById(@PathVariable String id){
        Type type = typeService.getById(id);
        return R.ok().data("typeInfo",type);
    }
}

